#pragma once
#include <thread>
#include "AVStreamInterface.h"
class AVStreamUtils : public av_stream_dev::IAVStreamUtils
{
public:
  AVStreamUtils();
	virtual ~AVStreamUtils() {}
  virtual bool OpenInputFile(std::string path, int nWidth, int nHeight, int nFrameRate, bool bFile);
  virtual void StartCapture();
  virtual void StopCapture();
  virtual void SetDataCallBack(av_stream_dev::IDataCallBack* ptr);
  virtual void SaveBmp(uint8_t* data, int nWidth, int nHeight, const char* fileName);

private:
  void DecodeStream(AVCodecContext* codexCtx, struct SwsContext* imageConvertCtx, AVFrame* frame, AVPacket* pkt);
  void DecodeFrame(struct SwsContext* imageConvertCtx, AVFrame* frame);

private:
  AVFormatContext* _inputFormatCtx;
  std::thread _processDataThd;
  uint8_t* _dataCallBack = nullptr;
  av_stream_dev::IDataCallBack* _pDataCallBack = nullptr;
  bool _isStop = false;
};

